###
 # @Author: isaac
 # @Date: 2022-12-07 11:38:59
 # @LastEditors: isaac
 # @LastEditTime: 2022-12-07 11:42:48
 # @Description: 
### 



# ------- RAM Usage ----------
RAM_SCRIPT='sketchybar -m --set ram label="RAM: $(memory_pressure | grep "System-wide memory free percentage:" | awk "{ print 100-\$5 }")%"'
sketchybar --add item ram right
sketchybar --set ram label.font="$TEXT_FONT:Normal:16.0"
sketchybar --set ram label.padding_right=$PADDING
sketchybar --set ram script="$RAM_SCRIPT"
sketchybar --set ram update_freq=2

# ------- CPU Usage ----------
CPU_SCRIPT='
CORE_COUNT=$(sysctl -n machdep.cpu.thread_count)
CPU_INFO=$(ps -eo pcpu,user)
CPU_SYS=$(echo "$CPU_INFO" | sed "s/[^ 0-9\.]//g" | awk "{sum+=\$1} END {print sum/(100.0 * $CORE_COUNT)}")
CPU_USE=$(printf "%02.0f"\\n "$(echo "$CPU_SYS*100"  | bc -l)")
sketchybar --set cpu label="CPU: ${CPU_USE}%"
'

sketchybar --add item cpu right
sketchybar --set cpu label.font="$TEXT_FONT:Normal:16.0"
sketchybar --set cpu script="$CPU_SCRIPT"
sketchybar --set cpu update_freq=2
sketchybar --set cpu label.padding_right=$PADDING